﻿<!DOCTYPE html>
<html>
<head>
    <:include file="../../common/css.html" title="富文本"/>
    <:include file="../../common/js.html"/>
    <script type="text/javascript" src="${ctxPath}/assets/libs/tinymce/tinymce.min.js"></script>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="emailForm">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">普通文本:</label>
                    <div class="layui-input-block">
                        <input name="input" class="layui-input" placeholder="请输入"
                               lay-verify="required" required/>
                    </div>
                </div>
                <:richText inForm="true" required="true" id="editor" label="富文本" accept="media" />
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="submit" lay-submit>&emsp;发&emsp;送&emsp;</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    layui.use(['layer', 'form', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;

        /* 表单提交 */
        form.on('submit(submit)', function (data) {
            data.field.richText = tinymce.get('editor').getContent();
            console.log(data.field.richText === '')
            if (data.field.richText === '') {
                layer.msg('请输入富文本', {icon: 2, anim: 6});
                return false;
            }

            layer.alert(JSON.stringify(data.field))

            // tinymce.get('editor').setContent('');

            return false;
        });

    });
</script>
</body>
</html>